using System;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;
using Oracle.ManagedDataAccess.Client;
using OracleInternal.Common;

namespace Oracle.ManagedDataAccess.Types
{
	[Serializable]
	[XmlSchemaProvider("GetXsdType")]
	public struct OracleDate : IComparable, INullable, IXmlSerializable
	{
		private bool m_bNotNull;

		internal byte[] m_byteRepresentation;

		private int m_year;

		private int m_month;

		private int m_day;

		private int m_hour;

		private int m_minute;

		private int m_second;

		internal const byte MaxArrSize = 7;

		internal const byte YEAR = 0;

		internal const byte MONTH = 1;

		internal const byte DAY = 2;

		internal const byte HOUR = 3;

		internal const byte MINUTE = 4;

		internal const byte SECOND = 5;

		public static readonly OracleDate MaxValue = new OracleDate(9999, 12, 31, 23, 59, 59);

		public static readonly OracleDate MinValue = new OracleDate(-4712, 1, 1, 0, 0, 0);

		public static readonly OracleDate Null;

		public byte[] BinData
		{
			get
			{
				if (m_bNotNull)
				{
					byte[] array = null;
					if (m_byteRepresentation != null)
					{
						array = new byte[7];
						Array.Copy(m_byteRepresentation, array, 7);
					}
					return array;
				}
				throw new OracleNullValueException();
			}
		}

		public bool IsNull => !m_bNotNull;

		public DateTime Value
		{
			get
			{
				if (m_bNotNull)
				{
					return DateTimeConv.GetDateTime(m_byteRepresentation, OracleDbType.Date);
				}
				throw new OracleNullValueException();
			}
		}

		public int Year
		{
			get
			{
				if (m_bNotNull)
				{
					return GetDateData(m_byteRepresentation, 0);
				}
				throw new OracleNullValueException();
			}
		}

		public int Month
		{
			get
			{
				if (m_bNotNull)
				{
					return GetDateData(m_byteRepresentation, 1);
				}
				throw new OracleNullValueException();
			}
		}

		public int Day
		{
			get
			{
				if (m_bNotNull)
				{
					return GetDateData(m_byteRepresentation, 2);
				}
				throw new OracleNullValueException();
			}
		}

		public int Hour
		{
			get
			{
				if (m_bNotNull)
				{
					return GetDateData(m_byteRepresentation, 3) - 1;
				}
				throw new OracleNullValueException();
			}
		}

		public int Minute
		{
			get
			{
				if (m_bNotNull)
				{
					return GetDateData(m_byteRepresentation, 4) - 1;
				}
				throw new OracleNullValueException();
			}
		}

		public int Second
		{
			get
			{
				if (m_bNotNull)
				{
					return GetDateData(m_byteRepresentation, 5) - 1;
				}
				throw new OracleNullValueException();
			}
		}

		internal byte[] InternalByteRepresentation => m_byteRepresentation;

		public OracleDate(int year, int month, int day, int hour, int minute, int second)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleDate, OracleTraceFuncName.ctor);
			}
			try
			{
				if (!TimeStamp.IsValidDateTime(year, month, day, hour, minute, second, 0))
				{
					throw new ArgumentOutOfRangeException();
				}
				m_bNotNull = true;
				m_byteRepresentation = new byte[7];
				m_byteRepresentation[0] = (byte)(year / 100 + 100);
				m_byteRepresentation[1] = (byte)(year % 100 + 100);
				m_byteRepresentation[2] = (byte)month;
				m_byteRepresentation[3] = (byte)day;
				m_byteRepresentation[4] = (byte)(hour + 1);
				m_byteRepresentation[5] = (byte)(minute + 1);
				m_byteRepresentation[6] = (byte)(second + 1);
				m_year = year;
				m_month = month;
				m_day = day;
				m_hour = hour;
				m_minute = minute;
				m_second = second;
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Public, OracleTraceTag.Error, OracleTraceClassName.OracleDate, OracleTraceFuncName.ctor, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleDate, OracleTraceFuncName.ctor);
				}
			}
		}

		public OracleDate(int year, int month, int day)
			: this(year, month, day, 0, 0, 0)
		{
		}

		public OracleDate(DateTime data)
			: this(data.Year, data.Month, data.Day, data.Hour, data.Minute, data.Second)
		{
		}

		public OracleDate(byte[] binData)
			: this(binData, bCopyData: true)
		{
		}

		public OracleDate(string datStr)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleDate, OracleTraceFuncName.ctor);
			}
			try
			{
				m_year = (m_month = (m_day = (m_hour = (m_minute = (m_second = 0)))));
				m_bNotNull = false;
				m_byteRepresentation = null;
				FromString(datStr);
				m_bNotNull = true;
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Public, OracleTraceTag.Error, OracleTraceClassName.OracleDate, OracleTraceFuncName.ctor, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleDate, OracleTraceFuncName.ctor);
				}
			}
		}

		internal OracleDate(byte[] binData, bool bCopyData, int offset = 0, int length = -1)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.OracleDate, OracleTraceFuncName.ctor);
			}
			try
			{
				if (binData == null)
				{
					throw new ArgumentNullException();
				}
				if (length == -1)
				{
					length = binData.Length;
				}
				if (length != 7)
				{
					throw new ArgumentException();
				}
				m_bNotNull = true;
				if (bCopyData)
				{
					m_byteRepresentation = new byte[length];
					Array.Copy(binData, offset, m_byteRepresentation, 0, length);
				}
				else
				{
					m_byteRepresentation = binData;
				}
				m_year = GetDateData(m_byteRepresentation, 0);
				m_month = GetDateData(m_byteRepresentation, 1);
				m_day = GetDateData(m_byteRepresentation, 2);
				m_hour = GetDateData(m_byteRepresentation, 3) - 1;
				m_minute = GetDateData(m_byteRepresentation, 4) - 1;
				m_second = GetDateData(m_byteRepresentation, 5) - 1;
				if (!TimeStamp.IsValidDateTime(m_year, m_month, m_day, m_hour, m_minute, m_second, 0))
				{
					throw new OverflowException();
				}
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, OracleTraceTag.Error, OracleTraceClassName.OracleDate, OracleTraceFuncName.ctor, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Exit, OracleTraceClassName.OracleDate, OracleTraceFuncName.ctor);
				}
			}
		}

		public static XmlQualifiedName GetXsdType(XmlSchemaSet schemaSet)
		{
			return new XmlQualifiedName("DateTime", "http://www.w3.org/2001/XMLSchema");
		}

		XmlSchema IXmlSerializable.GetSchema()
		{
			return null;
		}

		void IXmlSerializable.ReadXml(XmlReader reader)
		{
			string attribute = reader.GetAttribute("null", "http://www.w3.org/2001/XMLSchema-instance");
			if (attribute == null || !XmlConvert.ToBoolean(attribute))
			{
				FromString(reader.ReadElementString());
				m_bNotNull = true;
			}
			else
			{
				m_bNotNull = false;
			}
		}

		void IXmlSerializable.WriteXml(XmlWriter writer)
		{
			if (m_bNotNull)
			{
				writer.WriteString(ToString());
			}
			else
			{
				writer.WriteAttributeString("xsi", "null", "http://www.w3.org/2001/XMLSchema-instance", "true");
			}
		}

		public override string ToString()
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleDate, OracleTraceFuncName.ToString);
			}
			try
			{
				if (m_bNotNull)
				{
					return DateTimeStringUtilities.ToString(m_year, m_month, m_day, m_hour, m_minute, m_second);
				}
				return "null";
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Public, OracleTraceTag.Error, OracleTraceClassName.OracleDate, OracleTraceFuncName.ToString, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleDate, OracleTraceFuncName.ToString);
				}
			}
		}

		public int CompareTo(object obj)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleDate, OracleTraceFuncName.CompareTo);
			}
			try
			{
				if (obj == null)
				{
					throw new ArgumentNullException("obj");
				}
				if (obj.GetType() != typeof(OracleDate))
				{
					throw new ArgumentException("obj");
				}
				return HelperClass.CompareBytes(m_byteRepresentation, ((OracleDate)obj).m_byteRepresentation);
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Public, OracleTraceTag.Error, OracleTraceClassName.OracleDate, OracleTraceFuncName.CompareTo, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleDate, OracleTraceFuncName.CompareTo);
				}
			}
		}

		public override bool Equals(object obj)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleDate, OracleTraceFuncName.Equals);
			}
			try
			{
				if (obj == null || obj.GetType() != typeof(OracleDate))
				{
					return false;
				}
				return CompareTo(obj) == 0;
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Public, OracleTraceTag.Error, OracleTraceClassName.OracleDate, OracleTraceFuncName.Equals, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleDate, OracleTraceFuncName.Equals);
				}
			}
		}

		public override int GetHashCode()
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleDate, OracleTraceFuncName.GetHashCode);
			}
			try
			{
				if (m_bNotNull)
				{
					return m_byteRepresentation.GetHashCode();
				}
				return 0;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleDate, OracleTraceFuncName.GetHashCode);
				}
			}
		}

		public int GetDaysBetween(OracleDate value1)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleDate, OracleTraceFuncName.GetDaysBetween);
			}
			try
			{
				if (m_bNotNull && value1.m_bNotNull)
				{
					if (this > value1)
					{
						return TimeStamp.GetDaysBetweenTimeStamp(m_byteRepresentation, value1.m_hour, value1.m_minute, value1.m_second, 0, m_year, m_month, m_day, value1.m_year, value1.m_month, value1.m_day, isPositive: true, OracleDbType.Date).Days;
					}
					if (this < value1)
					{
						return TimeStamp.GetDaysBetweenTimeStamp(value1.InternalByteRepresentation, m_hour, m_minute, m_second, 0, value1.m_year, value1.m_month, value1.m_day, m_year, m_month, m_day, isPositive: false, OracleDbType.Date).Days;
					}
					return 0;
				}
				throw new OracleNullValueException();
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Public, OracleTraceTag.Error, OracleTraceClassName.OracleDate, OracleTraceFuncName.GetDaysBetween, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleDate, OracleTraceFuncName.GetDaysBetween);
				}
			}
		}

		public OracleTimeStamp ToOracleTimeStamp()
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleDate, OracleTraceFuncName.ToOracleTimeStamp);
			}
			try
			{
				if (m_bNotNull)
				{
					return new OracleTimeStamp(m_year, m_month, m_day, m_hour, m_minute, m_second);
				}
				return OracleTimeStamp.Null;
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Public, OracleTraceTag.Error, OracleTraceClassName.OracleDate, OracleTraceFuncName.ToOracleTimeStamp, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleDate, OracleTraceFuncName.ToOracleTimeStamp);
				}
			}
		}

		public static bool Equals(OracleDate value1, OracleDate value2)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleDate, OracleTraceFuncName.Equals);
			}
			try
			{
				return InternalTypes.CompareNull(!value1.m_bNotNull, !value2.m_bNotNull) switch
				{
					CompareNullEnum.BothNull => true, 
					CompareNullEnum.BothNotNull => value1.CompareTo(value2) == 0, 
					_ => false, 
				};
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Public, OracleTraceTag.Error, OracleTraceClassName.OracleDate, OracleTraceFuncName.Equals, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleDate, OracleTraceFuncName.Equals);
				}
			}
		}

		public static bool GreaterThan(OracleDate value1, OracleDate value2)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleDate, OracleTraceFuncName.GreaterThan);
			}
			try
			{
				return value1.CompareTo(value2) == 1;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleDate, OracleTraceFuncName.GreaterThan);
				}
			}
		}

		public static bool GreaterThanOrEqual(OracleDate value1, OracleDate value2)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleDate, OracleTraceFuncName.GreaterThanOrEqual);
			}
			try
			{
				return value1.CompareTo(value2) >= 0;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleDate, OracleTraceFuncName.GreaterThanOrEqual);
				}
			}
		}

		public static bool LessThan(OracleDate value1, OracleDate value2)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleDate, OracleTraceFuncName.LessThan);
			}
			try
			{
				return value1.CompareTo(value2) == -1;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleDate, OracleTraceFuncName.LessThan);
				}
			}
		}

		public static bool LessThanOrEqual(OracleDate value1, OracleDate value2)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleDate, OracleTraceFuncName.LessThanOrEqual);
			}
			try
			{
				return value1.CompareTo(value2) <= 0;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleDate, OracleTraceFuncName.LessThanOrEqual);
				}
			}
		}

		public static bool NotEquals(OracleDate value1, OracleDate value2)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleDate, OracleTraceFuncName.NotEquals);
			}
			try
			{
				return value1.CompareTo(value2) != 0;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleDate, OracleTraceFuncName.NotEquals);
				}
			}
		}

		public static OracleDate GetSysDate()
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleDate, OracleTraceFuncName.GetSysDate);
			}
			try
			{
				return new OracleDate(DateTime.Now);
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Public, OracleTraceTag.Error, OracleTraceClassName.OracleDate, OracleTraceFuncName.GetSysDate, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleDate, OracleTraceFuncName.GetSysDate);
				}
			}
		}

		public static OracleDate Parse(string datStr)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleDate, OracleTraceFuncName.Parse);
			}
			try
			{
				return new OracleDate(datStr);
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Public, OracleTraceTag.Error, OracleTraceClassName.OracleDate, OracleTraceFuncName.Parse, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleDate, OracleTraceFuncName.Parse);
				}
			}
		}

		public static bool operator ==(OracleDate value1, OracleDate value2)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleDate, OracleTraceFuncName.OperatorEqualTo);
			}
			try
			{
				return Equals(value1, value2);
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleDate, OracleTraceFuncName.OperatorEqualTo);
				}
			}
		}

		public static bool operator >(OracleDate value1, OracleDate value2)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleDate, OracleTraceFuncName.OperatorGreaterThan);
			}
			try
			{
				return GreaterThan(value1, value2);
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleDate, OracleTraceFuncName.OperatorGreaterThan);
				}
			}
		}

		public static bool operator >=(OracleDate value1, OracleDate value2)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleDate, OracleTraceFuncName.OperatorGreaterThanOrEqualTo);
			}
			try
			{
				return GreaterThanOrEqual(value1, value2);
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleDate, OracleTraceFuncName.OperatorGreaterThanOrEqualTo);
				}
			}
		}

		public static bool operator <(OracleDate value1, OracleDate value2)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleDate, OracleTraceFuncName.OperatorLessThan);
			}
			try
			{
				return LessThan(value1, value2);
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleDate, OracleTraceFuncName.OperatorLessThan);
				}
			}
		}

		public static bool operator <=(OracleDate value1, OracleDate value2)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleDate, OracleTraceFuncName.OperatorLessThanOrEqualTo);
			}
			try
			{
				return LessThanOrEqual(value1, value2);
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleDate, OracleTraceFuncName.OperatorLessThanOrEqualTo);
				}
			}
		}

		public static bool operator !=(OracleDate value1, OracleDate value2)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleDate, OracleTraceFuncName.OperatorNotEqualTo);
			}
			try
			{
				return NotEquals(value1, value2);
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleDate, OracleTraceFuncName.OperatorNotEqualTo);
				}
			}
		}

		public static explicit operator OracleDate(OracleTimeStamp value1)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleDate, OracleTraceFuncName.ctor);
			}
			try
			{
				if (!value1.IsNull)
				{
					byte[] byteRepresentation = value1.m_byteRepresentation;
					byte[] array = new byte[7];
					Array.Copy(byteRepresentation, array, 7);
					return new OracleDate(array, bCopyData: false);
				}
				return Null;
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Public, OracleTraceTag.Error, OracleTraceClassName.OracleDate, OracleTraceFuncName.ctor, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleDate, OracleTraceFuncName.ctor);
				}
			}
		}

		public static explicit operator OracleDate(string dateStr)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleDate, OracleTraceFuncName.ctor);
			}
			try
			{
				return new OracleDate(dateStr);
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Public, OracleTraceTag.Error, OracleTraceClassName.OracleDate, OracleTraceFuncName.ctor, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleDate, OracleTraceFuncName.ctor);
				}
			}
		}

		public static explicit operator DateTime(OracleDate value1)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleDate, OracleTraceFuncName.DateTime);
			}
			try
			{
				if (value1.m_bNotNull)
				{
					return DateTimeConv.GetDateTime(value1.m_byteRepresentation, OracleDbType.Date);
				}
				throw new OracleNullValueException();
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Public, OracleTraceTag.Error, OracleTraceClassName.OracleDate, OracleTraceFuncName.DateTime, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleDate, OracleTraceFuncName.DateTime);
				}
			}
		}

		public static explicit operator OracleDate(DateTime value1)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleDate, OracleTraceFuncName.ctor);
			}
			try
			{
				return new OracleDate(value1);
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Public, OracleTraceTag.Error, OracleTraceClassName.OracleDate, OracleTraceFuncName.ctor, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleDate, OracleTraceFuncName.ctor);
				}
			}
		}

		internal static int GetDateData(byte[] byteRep, byte tsComponent)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.OracleDate, OracleTraceFuncName.GetDateData);
			}
			try
			{
				int result = 0;
				switch (tsComponent)
				{
				case 0:
					result = (byteRep[0] - 100) * 100 + (byteRep[1] - 100);
					break;
				case 1:
					result = byteRep[2] & 0xFF;
					break;
				case 2:
					result = byteRep[3] & 0xFF;
					break;
				case 3:
					result = byteRep[4] & 0xFF;
					break;
				case 4:
					result = byteRep[5] & 0xFF;
					break;
				case 5:
					result = byteRep[6] & 0xFF;
					break;
				}
				return result;
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, OracleTraceTag.Error, OracleTraceClassName.OracleDate, OracleTraceFuncName.GetDateData, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Exit, OracleTraceClassName.OracleDate, OracleTraceFuncName.GetDateData);
				}
			}
		}

		internal static byte[] ToBytes(int year, int month, int day, int hour, int minute, int second)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.OracleDate, OracleTraceFuncName.ToBytes);
			}
			try
			{
				return new byte[7]
				{
					(byte)(year / 100 + 100),
					(byte)(year % 100 + 100),
					(byte)month,
					(byte)day,
					(byte)(hour + 1),
					(byte)(minute + 1),
					(byte)(second + 1)
				};
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, OracleTraceTag.Error, OracleTraceClassName.OracleDate, OracleTraceFuncName.ToBytes, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Exit, OracleTraceClassName.OracleDate, OracleTraceFuncName.ToBytes);
				}
			}
		}

		private void FromString(string datStr)
		{
			if (datStr == null)
			{
				throw new ArgumentNullException();
			}
			int nanos = 0;
			string region = null;
			DateTimeStringUtilities.FromString(datStr, out m_year, out m_month, out m_day, out m_hour, out m_minute, out m_second, out nanos, out region, expectNoRegion: true, expectNoNanos: true);
			m_byteRepresentation = ToBytes(m_year, m_month, m_day, m_hour, m_minute, m_second);
		}
	}
}
